﻿//using BaseUtils.Logger;
//using Microsoft.Web.WebView2.WinForms;
//using Service.src.Api;
//using Service.src.Flow.Api;
//using System;

//namespace Service.src.NW.UI
//{
//    internal class WebView2HandlerTemp
//    {
//        public static WebView2 UIGeneratorView2;

//        /// <summary>
//        /// 初始化页面
//        /// </summary>
//        public static void InitWebView2(string URL)
//        {
//            //string URL = AppDomain.CurrentDomain.BaseDirectory + ConfigurationManager.AppSettings.Get("UIURL");
//            //string URL = "http://localhost:9528/#/flow";
//            LoggerService.Info(URL);
//            UIGeneratorView2.Source = new Uri(URL);
//        }

//        /// <summary>
//        /// 监听页面是否加载完成
//        /// </summary>
//        /// <param name="sender"></param>
//        /// <param name="e"></param>
//        public static void MainView_NavigationCompleted(
//            object sender,
//            Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e,
//            string Route)
//        {
//            // 检查是否成功加载页面
//            if (e.IsSuccess)
//            {
//                UIGeneratorView2.CoreWebView2.AddHostObjectToScript("FlowApi", new FlowApi());
//                UIGeneratorView2.CoreWebView2.AddHostObjectToScript("SourceNodeGroupApi", new SourceNodeGroupApi());
//                UIGeneratorView2.CoreWebView2.AddHostObjectToScript("SysDeviceApi", new SysDeviceApi());
//                UIGeneratorView2.CoreWebView2.AddHostObjectToScript("SysPlcDriverAddressApi", new SysPlcDriverAddressApi());
//                UIGeneratorView2.CoreWebView2.AddHostObjectToScript("FlowRuntimeApi", new FlowRuntimeApi());
//                UIGeneratorView2.CoreWebView2.AddHostObjectToScript("SystemApi", new SystemApi());
//                UIGeneratorView2.CoreWebView2.AddHostObjectToScript("EventApi", new EventApi());
//                UIGeneratorView2.CoreWebView2.AddHostObjectToScript("DataManageApi", new DataManageApi());
//                UIGeneratorView2.CoreWebView2.AddHostObjectToScript("UserPageApi", new UserPageApi());
//                UIGeneratorView2.CoreWebView2.AddHostObjectToScript("GlobalParamApi", new GlobalParamApi());
//                UIGeneratorView2.CoreWebView2.AddHostObjectToScript("UserPageProjectApi", new UserPageProjectApi());

//                //AppData.AppRunSuccessed();
//                LoggerService.Info("页面加载完成");
//                //InitWebView2($"http://localhost:5173/#/{Route}");
//                InitWebView2($"{Route}");
//            }
//            else
//            {
//                LoggerService.Info("页面加载失败" + e.WebErrorStatus);
//            }
//        }
//    }
//}
